import { locations } from "../../../../gpu/locations";
export const DisplacementMap_def = /*wgsl*/ `
#if ~{def.displacementMap && def.normal && def.texCood0}
  @group(${locations.displacementMap[0]}) @binding(${locations.displacementMap[1]}) var displacementMap: texture_2d<f32>;
  @group(${locations.displacementScale[0]}) @binding(${locations.displacementScale[1]}) var<uniform> displacementScale : f32;
  @group(${locations.displacementBias[0]}) @binding(${locations.displacementBias[1]}) var<uniform> displacementBias : f32;
  fn cal_displacementTrans(vertexInput:VertexInput)->vec3<f32>{
    var uv = vertexInput.texCood0;
    let texSize = textureDimensions(displacementMap).xy;
    return normalize(vertexInput.normal) * textureLoad(displacementMap, vec2<i32>( i32(uv.x * f32(texSize.x)), i32(uv.y * f32(texSize.y))), 0).x * displacementScale + displacementBias;
  }
#endif
`
